import { BookItem } from "../types/book";
import { PageParams, PageResult } from "../types/global";
import { RankItem, SearchParams } from "../types/rank";
import { http } from "@/utils/http";


/**
 * 查询排行榜一级数据
 * @param ranktTitle 榜单标题
 * @returns 一级榜单数据
 */
export const listOneRankAPI = () => {
	return http<RankItem[]>({
		url: '/fanqie/ranks/listOneRank',
		method: 'GET',

	})
};


/**
 *  查看排行榜下的数据
 * @param rankId 榜单id
 * @returns 推荐榜单数据
 */
export const listRecommendBooksByRankIdAPI = (rankId : number) => {
	return http<BookItem[]>({
		url: '/fanqie/bookRanksRelation/listRecommendBooksByRankId',
		method: 'GET',
		data: {
			rankId: rankId,
		}
	})
};

/**
 *  树查询所有排行榜
 * @returns 所有排行榜
 */
export const queryAllRankListAPI = () => {
	return http<RankItem[]>({
		url: '/fanqie/ranks/queryAllRankList',
		method: 'GET',
	})
};

/**
 *  查询排行榜列表
 * @param primaryId 一级分类id
 * @param secondaryId  二级分类id
 * @returns 排行榜列表，只有30条数据
 */
export const pageBooksByRankAPI = (
	params : SearchParams,
	pageParams : PageParams,
) => {
	return http<PageResult<BookItem[]>>({
		url: '/fanqie/bookRanksRelation/pageBooksByRank',
		method: 'GET',
		data: {
			current: pageParams.current,
			size: pageParams.size,
			parentRankId: params.parentRankId,
			rankId: params.rankId,
		}
	})

};